/**
 * Project: topdt-jbpm
 * Copyright 2013  Top Digital Technology  Co. Ltd.
 * All right reserved.
 */
package com.topdt.jbpm.service;

import java.util.ArrayList;
import java.util.List;

/**
 * 建立日期 : 2013-6-8 上午10:15:04<br>
 * 作者 : balance<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
public class OutComeResp extends SubmitResp {
	private boolean backable;

	private boolean restartable;

	List<OutCome> outComes;

	public OutComeResp() {
		this.type = TYPE_OUTCOME;
	}

	public List<OutCome> getOutComes() {
		return outComes;
	}

	public void setOutComes(List<OutCome> outComes) {
		this.outComes = outComes;
	}

	public void addOutCome(String outCome, boolean checked) {
		if (outComes == null)
			outComes = new ArrayList<OutCome>();

		outComes.add(new OutCome(outCome, checked));
	}

	public void addDefaultCome(String name) {
		if (outComes == null)
			outComes = new ArrayList<OutCome>();
		OutCome come = new OutCome(name, false);
		come.setDefaulted(true);
		outComes.add(come);
	}

	public void addBackCome() {
		if (outComes == null)
			outComes = new ArrayList<OutCome>();

		OutCome come = new OutCome("返回上一步", false);
		come.setBackable(true);
		outComes.add(come);
		this.backable = true;
	}

	public void addReStartCome() {
		if (outComes == null)
			outComes = new ArrayList<OutCome>();

		OutCome come = new OutCome("退回起草", false);
		come.setRestartable(true);
		outComes.add(come);
		this.restartable = true;
	}
	//add by calonlan 添加回退某个节点的出口流转
	public void addOtherBackCome(String outCome) {
		if (outComes == null) {
			outComes = new ArrayList<OutCome>();
		}
		OutCome come = new OutCome(outCome, false);
		come.setOtherbackable(true);
		outComes.add(come);
		
	}

	public void setTodoId(String todoId) {
		this.todoId = todoId;
	}

	public int size() {
		return this.outComes.size();
	}

	public boolean hasBackOut() {
		return this.backable;
	}

	public boolean hasRestartOut() {
		return this.restartable;
	}

	public String getUniqueOut() {
		return outComes.get(0).getOutCome();
	}

	class OutCome {
		private String outCome;

		private boolean checked;

		private boolean backable;

		private boolean restartable;

		private boolean defaulted;
		//add by calonlan 是否回退到某个节点
		private boolean otherbackable;
		

		public OutCome(String outCome, boolean checked) {
			this.outCome = outCome;
			this.checked = checked;
		}

		public String getOutCome() {
			return outCome;
		}

		public void setOutCome(String outCome) {
			this.outCome = outCome;
		}

		public boolean isChecked() {
			return checked;
		}

		public void setChecked(boolean checked) {
			this.checked = checked;
		}

		public boolean isBackable() {
			return backable;
		}

		public void setBackable(boolean backable) {
			this.backable = backable;
		}

		public boolean isRestartable() {
			return restartable;
		}

		public void setRestartable(boolean restartable) {
			this.restartable = restartable;
		}

		public boolean isDefaulted() {
			return defaulted;
		}

		public void setDefaulted(boolean defaulted) {
			this.defaulted = defaulted;
		}

		public boolean isOtherbackable() {
			return otherbackable;
		}

		public void setOtherbackable(boolean otherbackable) {
			this.otherbackable = otherbackable;
		}
		
		

	}
}
